﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Newtonsoft.Json;
using System.Collections.Generic;

public partial class Rep_InvestmentReturn : System.Web.UI.Page
{
    BLL.BLLValRep br = new BLL.BLLValRep();
    IList<Hashtable> list = null;
    object obj = null;
    protected void Page_Load(object sender, EventArgs e)
    {

        string param = Request["param"];
        if (param != "")
        {
            if (param == "query")
            {
                string id = Request["id"].ToString();
                string sTime = Convert.ToDateTime(Request["sTime"]).ToString("yyyy-MM-dd HH:mm:ss");
                string eTime = Convert.ToDateTime(Request["eTime"]).ToString("yyyy-MM-dd HH:mm:ss");
                QueryTableList(id, sTime, eTime);
            }
        }
        else
        {
            QueryTableList("", DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss"), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
        }
    }
    protected void QueryTableList(string id, string sTime, string eTime)
    {
        if (Convert.ToDateTime(sTime) >= Convert.ToDateTime(eTime))
        {
            obj = new
            {
                tableInfo = "结束时间必须大于开始时间",
            };
            string result = JavaScriptConvert.SerializeObject(obj);
            Response.Write(result);
            Response.End();
        }
        else
            if (id == "")
            {
                list = br.getQTPoint();
                string strApp = br.getQTjs(id, Convert.ToDateTime(sTime), Convert.ToDateTime(eTime));
                int index = strApp.IndexOf(',');
                int length = Convert.ToInt32(strApp.Substring(0, index));
                strApp = strApp.Remove(0, index + 1);

                obj = new
                {
                    count = length,
                    tableInfo = strApp,
                    list = list
                };
                string result = JavaScriptConvert.SerializeObject(obj);
                Response.Write(result);
                Response.End();
            }
            else
            {
                string strApp = br.getQTjs(id, Convert.ToDateTime(sTime), Convert.ToDateTime(eTime));
                int index = strApp.IndexOf(',');
                int length = Convert.ToInt32(strApp.Substring(0, index));
                strApp = strApp.Remove(0, index + 1);
                obj = new
                {
                    count = length,
                    tableInfo = strApp
                };
                string result = JavaScriptConvert.SerializeObject(obj);
                Response.Write(result);
                Response.End();
            }

    }
}